/*
 * @Description: 设备属性接口
 * @Author: Huang Junjie
 * @Date: 2021-09-14 16:52:40
 * @LastEditTime: 2021-09-28 13:22:39
 * @LastEditors: Huang Junjie
 */
import request from '@/utils/request'

// 查询列表信息
export function getListPage(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwDeviceclassCitem/pageData') : '/jcwBasic/jcwDeviceclassCitem/pageData',
    method: 'GET',
    params: params
  })
}

// 根据id查询信息
export function getInfoById(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwDeviceclassCitem/getById`) : `/jcwBasic/jcwDeviceclassCitem/getById`,
    method: 'GET',
    params: params
  })
}

// 新增/修改信息
export function addOrEditData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwDeviceclassCitem/saveOrUpdateData') : '/jcwBasic/jcwDeviceclassCitem/saveOrUpdateData',
    method: 'POST',
    data: params
  })
}

// 更改状态
export function updateStatus(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwDeviceclassCitem/updateStatus') : '/jcwBasic/jcwDeviceclassCitem/updateStatus',
    method: 'POST',
    data: params
  })
}

// 删除信息
export function deleteData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwDeviceclassCitem/${params.id}`) : `/jcwBasic/jcwDeviceclassCitem/${params.id}`,
    method: 'DELETE'
  })
}

// 查询属性下拉框列表信息
export function getAttrInfoById(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwValueSet/getById`) : `/jcwBasic/jcwValueSet/getById`,
    method: 'GET',
    params: params
  })
}

// 保存属性配置
export function updateAttrData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwValueSet/saveOrUpdateData') : '/jcwBasic/jcwValueSet/saveOrUpdateData',
    method: 'POST',
    data: params
  })
}
